package com.prs.crm.domain.ca.work;




import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;


import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.cdxh.NewPlanOrderDetail;
import com.prs.crm.domain.flow.WorkFlow;
import com.prs.crm.domain.flow.WorkFlowInstance;
import com.prs.crm.domain.flow.WorkFlowProcess;
/**
 * @author YangHao
 * @E-Mail:450098606@qq.com
 * @qq:450098606
 * @version 创建时间 2012-3-28 14:12:32 采购申请
 */
@Entity
@Table(name="ca_purchaseApply")
public class PurchaseApply extends BaseEntity{
	private static final long serialVersionUID = -3118764504818417101L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	/**
	 * 采购申请单号
	 */
	private String pa_billNumber;
	/**
	 * 采购申请申请人
	 */
	private String pa_applyPerson;
	/**
	 * 采购申请申请日期
	 */
	private Date pa_applyDate;
	/**
	 * 采购申请金额合计
	 */
	@Column(columnDefinition = "Double(11,3) default '0.000'")
	private Double pa_totalMoney;
	/**
	 * 采购申请审批状态
	 */
	private Integer pa_examineState;// 0表示未提交1审批中2已完成3撤销申请4未通过
	/**
	 * 采购申请审批人
	 */
	private String pa_examinePerson;
	/**
	 * 采购申请审批步骤
	 */
	private Integer pa_examineProcedure ;// 1申请者2部门经理3总经理4财务经理5出纳
	
	/**
	 * 设置是否显示
	 * 1：显示 
	 */
	private String showstate;
	private String personAppProcess;
	private Integer personAppState;

	@OneToMany(mappedBy = "purchaseApply")
	@Cascade({ org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<DemandInventory> demandInventorys;
	
	@OneToMany(mappedBy = "purchaseApply")
	@Cascade({ org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private List<PurchaseAppplyDetail> purchaseAppplyDetail;
	private String appName;
	private String type;
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	private Attachment attach; 
	
	@OneToOne
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
		org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private WorkFlowProcess process;
	@ManyToOne
	private WorkFlowInstance workFlowInstance;
	
	@ManyToOne
	private WorkFlow workFlow;
	

public List<PurchaseAppplyDetail> getPurchaseAppplyDetail() {
		return purchaseAppplyDetail;
	}
	public void setPurchaseAppplyDetail(
			List<PurchaseAppplyDetail> purchaseAppplyDetail) {
		this.purchaseAppplyDetail = purchaseAppplyDetail;
	}
public String getPersonAppProcess() {
		return personAppProcess;
	}
	public void setPersonAppProcess(String personAppProcess) {
		this.personAppProcess = personAppProcess;
	}
	public Integer getPersonAppState() {
		return personAppState;
	}
	public void setPersonAppState(Integer personAppState) {
		this.personAppState = personAppState;
	}
	//	private 
	public WorkFlow getWorkFlow() {
		return workFlow;
	}
	public void setWorkFlow(WorkFlow workFlow) {
		this.workFlow = workFlow;
	}
	public WorkFlowInstance getWorkFlowInstance() {
		return workFlowInstance;
	}
	public void setWorkFlowInstance(WorkFlowInstance workFlowInstance) {
		this.workFlowInstance = workFlowInstance;
	}
	public WorkFlowProcess getProcess() {
		return process;
	}
	public void setProcess(WorkFlowProcess process) {
		this.process = process;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getAppName() {
		return appName;
	}
	public void setAppName(String appName) {
		this.appName = appName;
	}
	public Attachment getAttach() {
		return attach;
	}
	public void setAttach(Attachment attach) {
		this.attach = attach;
	}
	public Set<DemandInventory> getDemandInventorys() {
		return demandInventorys;
	}
	public void setDemandInventorys(Set<DemandInventory> demandInventorys) {
		this.demandInventorys = demandInventorys;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getPa_billNumber() {
		return pa_billNumber;
	}
	public void setPa_billNumber(String paBillNumber) {
		pa_billNumber = paBillNumber;
	}
	public String getPa_applyPerson() {
		return pa_applyPerson;
	}
	public void setPa_applyPerson(String paApplyPerson) {
		pa_applyPerson = paApplyPerson;
	}
	
	public Date getPa_applyDate() {
		return pa_applyDate;
	}
	public void setPa_applyDate(Date paApplyDate) {
		pa_applyDate = paApplyDate;
	}
	
	public Double getPa_totalMoney() {
		return pa_totalMoney;
	}
	public void setPa_totalMoney(Double paTotalMoney) {
		pa_totalMoney = paTotalMoney;
	}
	
	public String getPa_examinePerson() {
		return pa_examinePerson;
	}
	public void setPa_examinePerson(String paExaminePerson) {
		pa_examinePerson = paExaminePerson;
	}
	
  public Integer getPa_examineState() {
		return pa_examineState;
	}
	public void setPa_examineState(Integer paExamineState) {
		pa_examineState = paExamineState;
	}
	public Integer getPa_examineProcedure() {
		return pa_examineProcedure;
	}
	public void setPa_examineProcedure(Integer paExamineProcedure) {
		pa_examineProcedure = paExamineProcedure;
	}
public void addDemandInventory(DemandInventory demandInventory){
	  if(demandInventorys==null){
		  demandInventorys = new HashSet<DemandInventory>();
	  }
	  demandInventory.setPurchaseApply(this);
	  demandInventorys.add(demandInventory);
  }
public String getShowstate() {
	return showstate;
}
public void setShowstate(String showstate) {
	this.showstate = showstate;
}
public void addPurchaseAppplyDetail(PurchaseAppplyDetail details) {
	if (purchaseAppplyDetail == null)
		purchaseAppplyDetail = new ArrayList<PurchaseAppplyDetail>();
	
	details.setPurchaseApply(this);
	purchaseAppplyDetail.add(details);
}
}
